package com.zhuss.want.processor;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.want.want.DeleteWantAppendBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.db.entity.OpLog;
import com.zhuss.enums.LogActionEnum;
import com.zhuss.enums.MoudleEnum;
import com.zhuss.exception.WpsException;
import com.zhuss.util.JsonUtil;
import com.zhuss.want.db.dao.ext.WantAppendDao;
import com.zhuss.want.db.entity.WantAppend;

/**
 * 删除求职Append processor
 * @Author: zhushanshuo
 * @Date: 2019/9/24 19:54
 */
@Component("wantAppendDelete")
public class WantAppendDelete extends AbstractProcessor<Object, DeleteWantAppendBo> implements Processor<Object, DeleteWantAppendBo> {

    @Autowired
    private WantAppendDao wantAppendDao;
    
    /**
     * 校验
     */
	@Override
    public void check(DeleteWantAppendBo bo) throws WpsException {
    	
    }
    
    /**
     * 操作方法
     */
    @Override
    public Object process(DeleteWantAppendBo param) throws WpsException {
    	Long wantAppendId = param.getWantAppendId();
    	
    	WantAppend record = new WantAppend();
    	record.setWantAppendId(wantAppendId);
    	record.setDeleted(param.getDeleted());
    	
    	record.setModifierId(param.getConcurrentUserId());
    	record.setModifier(param.getConcurrentUserName());
    	record.setModifyTime(new Date());
    	wantAppendDao.delete(record);
        return null;
    }
    
    /**
     * 操作日志
     */
	@Override
	public Object log(DeleteWantAppendBo param) throws WpsException {
		OpLog record = new OpLog();
    	record.setMoudle(MoudleEnum.求职.key());
    	record.setAction(LogActionEnum.求职Append删除.key());
    	record.setTargetId(param.getWantAppendId());
    	record.setTargetName(param.getWantAppendId() + "");
    	record.setContent("参数: " + JsonUtil.toJson(param));
    	record.setReason(param.getExceptionReason());
    	
    	record.setCreatorId(param.getConcurrentUserId());
    	record.setCreator(param.getConcurrentUserName());
    	record.setCreateTime(new Date());
    	log(record);
    	return null;
	}
}
